package com.xwj.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author xwj
 * @date 2020/6/8
 */
@Configuration
public class RedissonConfig {
    @Value("${redisson.address}")
    private String address;
    @Bean
    public RedissonClient redissonClient() {
        Config config = new Config();
        // 单节点
//        config.useSingleServer().setAddress(address).setKeepAlive(true);
        // 集群节点
        config.useClusterServers().addNodeAddress("redis://192.168.1.156:7000", "redis://192.168.1.156:7001", "redis://192.168.1.156:7002");
        return Redisson.create(config);
    }
}
